using MediatR;
using RBAC.ErrorCode;
using System.Collections.Generic;

namespace RBAC.Write.Api.Application.Command.ERP.PurchasingManagement.PurchaseOrders
{

    /// <summary>
    /// 添加采购订单命令
    /// </summary>
    public class AddPurchaseOrderCommand:IRequest<APIResult<int>>
    {


        /// <summary>
        /// 单据编码
        /// </summary>
        public string DocCode { get; set; }

        /// <summary>
        /// 业务类型
        /// </summary>
        public string BizType { get; set; }

        /// <summary>
        /// 操作员
        /// </summary>
        public string Operatorer { get; set; }

        /// <summary>
        /// 供应商ID
        /// </summary>
        public string supplierId { get; set; }

        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime docDate { get; set; }

        /// <summary>
        /// 单据类型
        /// </summary>
        public string docType { get; set; }

        /// <summary>
        /// 审批员
        /// </summary>
        private string auditor { get; set; }

        /// <summary>
        /// 到货日期
        /// </summary>
        public DateTime arrivalDate { get; set; }

        /// <summary>
        /// 单据状态（如草稿、已审批等）
        /// </summary>
        public string docStatus { get; set; }

        /// <summary>
        /// 采购部门
        /// </summary>
        public string purchaseDept { get; set; }

        /// <summary>
        /// 审批日期
        /// </summary>
        public DateTime auditDate { get; set; }

        /// <summary>
        /// 合同上传路径
        /// </summary>
        public string contractUpload { get; set; }

        /// <summary>
        /// 业务状态
        /// </summary>
        public string bizStatus { get; set; }

        /// <summary>
        /// 采购人员
        /// </summary>
        public string purchaser { get; set; }

        /// <summary>
        /// 用料需求说明
        /// </summary>
        public string materialDemand { get; set; }

        /// <summary>
        /// 合同号
        /// </summary>
        public string contractNo { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string remark { get; set; }

        /// <summary>
        /// 关联的采购物料明细列表
        /// </summary>
        public List<int> purchaseDetailsId;



        /// <summary>
        /// 单据编号
        /// </summary>
        public string DocumentaryNumber { get; set; } = null;

        /// <summary>
        /// 计划单号
        /// </summary>
        public string PlannedOrderNumber { get; set; } = null;

        /// <summary>
        /// 物料编码
        /// </summary>
        public string materialCode { get; set; } = null;

        /// <summary>
        /// 物料名称
        /// </summary>
        public string materialName { get; set; } = null;

        /// <summary>
        /// 型号规格
        /// </summary>
        public string modelSpec { get; set; }

        /// <summary>
        /// 主计量单位
        /// </summary>
        public string mainUnit { get; set; }

        /// <summary>
        /// 需求日期
        /// </summary>
        public DateTime demandDate { get; set; }

        /// <summary>
        /// 采购数量
        /// </summary>
        public int qty { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal unitPrice { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        public decimal amount { get; set; }
/// <summary>
/// 到货数量
/// </summary>
        public int arrivalQty { get; set; }
/// <summary>
/// 采购说明
/// </summary>
        public string? PurchasingInstructions { get; set; }

        /// <summary>
        /// 采购订单明细集合
        /// </summary>
        public List<PurchaseOrderDetailDto> Details { get; set; } = new();
    }

    /// <summary>
    /// 采购订单明细DTO
    /// </summary>
    public class PurchaseOrderDetailDto
    {
        public string? DocumentaryNumber { get; set; }
        public string? PlannedOrderNumber { get; set; }
        public string? materialCode { get; set; }
        public string? materialName { get; set; }
        public string? modelSpec { get; set; }
        public string? mainUnit { get; set; }
        public DateTime demandDate { get; set; }
        public int qty { get; set; }
        public decimal unitPrice { get; set; }
        public decimal? amount { get; set; }
        public int arrivalQty { get; set; }
        public string? PurchasingInstructions { get; set; }
    }
}
